package io.renren.modules.work.controller;

import java.util.Arrays;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import io.renren.modules.work.entity.ScConsumablesEntity;
import io.renren.modules.work.service.ScConsumablesService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 耗材
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-05-08 23:01:13
 */
@RestController
@RequestMapping("work/scconsumables")
public class ScConsumablesController {
    @Autowired
    private ScConsumablesService scConsumablesService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("work:scconsumables:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = scConsumablesService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{consumablesid}")
    @RequiresPermissions("work:scconsumables:info")
    public R info(@PathVariable("consumablesid") String consumablesid){
		ScConsumablesEntity scConsumables = scConsumablesService.getById(consumablesid);

        return R.ok().put("scConsumables", scConsumables);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("work:scconsumables:save")
    public R save(@RequestBody ScConsumablesEntity scConsumables){
		scConsumablesService.save(scConsumables);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("work:scconsumables:update")
    public R update(@RequestBody ScConsumablesEntity scConsumables){
		scConsumablesService.updateById(scConsumables);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("work:scconsumables:delete")
    public R delete(@RequestBody String[] consumablesids){
		scConsumablesService.removeByIds(Arrays.asList(consumablesids));

        return R.ok();
    }

}
